'   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 '           N a m e : 	 W X M _ L A S E R _ E n g r a v e r _ 2 . t x t                             D a t e :   2 0   O c t o b e r   2 0 1 9 
 
 '         A u t o r :   L e o n a r d o   D E   P A L O   P h . D . 
 
 '         S c o p e :   G e n e r a t i n g   a   t e s t   r o b o t   f o r   D o o r L o c k   s y s t e m 
 
 '   H a r d w a r e :   U s i n g   o l d   c a r t e s i a n   s y s t e m ,   M i c r o v i d e o   a n d   a u d i o   s p e a c h . 
 
 '   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 
 
 L o a d   D o o r B e l l . w a v 
 
 S p e e d   9 
 
 B u t t o n   1   T e x t   " H O M E   A l l " 
 
 
 
 B u t t o n   3   T e x t   " L A S E R       0 % " 
 
 B u t t o n   4   T e x t   " L A S E R     3 3 % " 
 
 B u t t o n   5   T e x t   " L A S E R     6 6 % " 
 
 B u t t o n   6   T e x t   " L A S E R   1 0 0 % " 
 
 
 
 B u t t o n   8   T e x t   " D R A W   S Q U A R E " 
 
 
 
 K e y   R i g h t 	 	 G o s u b   M o v e R i g h t 
 
 K e y   L e f t   	 	 G o s u b   M o v e L e f t 
 
 K e y   U p   	 	 	 G o s u b   M o v e F a r 
 
 K e y   D o w n   	 	 G o s u b   M o v e N e a r 
 
 K e y   P a g e u p 	 	 G o s u b   M o v e U p 
 
 K e y   P a g e d o w n 	 G o s u b   M o v e D o w n 
 
 
 
 V a r i a b l e   N u m e r i c   S t a r t X 
 
 V a r i a b l e   N u m e r i c   S t a r t Y 
 
 V a r i a b l e   N u m e r i c   S t a r t Z 
 
 
 
 V a r i a b l e   N u m e r i c   C o o r d _ X 
 
 V a r i a b l e   N u m e r i c   C o o r d _ Y 
 
 V a r i a b l e   N u m e r i c   C o o r d _ Z 
 
 
 
 V a r i a b l e   N u m e r i c   C u t S p e e d 
 
 V a r i a b l e   N u m e r i c   M o v e B y 
 
 
 
 V a r i a b l e   N u m e r i c   S l o t M o t o r 
 
 V a r i a b l e   N u m e r i c   S l o t S e n s o r 
 
 V a r i a b l e   N u m e r i c   S p e e d S e a r c h 
 
 V a r i a b l e   N u m e r i c   S p e e d R e t u r n 
 
 V a r i a b l e   N u m e r i c   D e c l a r e d Z e r o 
 
 V a r i a b l e   N u m e r i c   I n i t i a l P o s i t i o n 
 
 V a r i a b l e   N u m e r i c   S l o t L a s e r P w m 
 
 
 
 V a r i a b l e   N u m e r i c   S l o t M o t o r X 
 
 V a r i a b l e   N u m e r i c   S l o t M o t o r Y 
 
 V a r i a b l e   N u m e r i c   S l o t M o t o r Z 
 
 
 
 S l o t M o t o r X   =   1 
 
 S l o t M o t o r Y   =   3 
 
 S l o t M o t o r Z   =   5 
 
 
 
 S l o t L a s e r P w m   =   3 0 
 
 
 
 S t a r t X   =   1 2 0 
 
 S t a r t Y   =   2 6 0 
 
 S t a r t Z   =   0 
 
 
 
 L o a d   T h e r e m i n o _ H A L \ T h e r e m i n o _ H A L . e x e 
 
 L o a d   T h e r e m i n o _ H A L \ T h e r e m i n o _ S l o t V i e w e r . e x e 
 
 
 
 S t o p 
 
 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 ' - - - - -   F   U   N   C   T   I   O   N     A   R   E   A     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 
 
 
 
 
 
 L a b e l   M o v e T o S t a r t 
 
 	 C o o r d _ X   =   S t a r t X 
 
 	 C o o r d _ Y   =   S t a r t Y 
 
 	 C o o r d _ Z   =   S t a r t Z 
 
 	 G o s u b   M o v e T o C o o r d s 
 
 R e t u r n 
 
 
 
 
 
 L a b e l   " L A S E R       0 % " 
 
 	 G o s u b   M o v e T o S t a r t 
 
 	 S l o t ( S l o t L a s e r P w m )   =   0 
 
 R e t u r n 
 
 
 
 L a b e l   " L A S E R     3 3 % " 
 
 	 G o s u b   M o v e T o S t a r t 
 
 	 S l o t ( S l o t L a s e r P w m )   =   3 3 3 
 
 R e t u r n 
 
 
 
 L a b e l   " L A S E R     6 6 % " 
 
 	 G o s u b   M o v e T o S t a r t 
 
 	 S l o t ( S l o t L a s e r P w m )   =   6 6 6 
 
 R e t u r n 
 
 
 
 L a b e l   " L A S E R   1 0 0 % " 
 
 	 G o s u b   M o v e T o S t a r t 
 
 	 S l o t ( S l o t L a s e r P w m )   =   1 0 0 0 
 
 R e t u r n 
 
 
 
 L a b e l   " D R A W   S Q U A R E " 
 
 	 G o s u b   M o v e T o S t a r t 
 
 	 C u t S p e e d   =   0 . 1 
 
 	 
 
 	 S l o t ( S l o t L a s e r P w m )   =   5 0 0 	 ' < < < < < < < < < < < < < < < < < < 
 
 	 
 
 	 M o v e B y   =   5 0 
 
 	 G o s u b   M o v e M o t o r X 
 
 	 
 
 	 M o v e B y   =   5 0 
 
 	 G o s u b   M o v e M o t o r Y 
 
 	 
 
 	 M o v e B y   =   - 5 0 
 
 	 G o s u b   M o v e M o t o r X 
 
 	 
 
 	 M o v e B y   =   - 5 0 
 
 	 G o s u b   M o v e M o t o r Y 
 
 	 
 
 	 S l o t ( S l o t L a s e r P w m )   =   0 
 
 R e t u r n 
 
 
 
 L a b e l   M o v e M o t o r X 
 
 	 v 2   =   S l o t ( S l o t M o t o r X ) 
 
 	 v 3   =   v 2   +   M o v e B y 
 
 	 F o r   v 1   =   v 2   T o   v 3   S t e p   C u t S p e e d 
 
 	 	 S l o t ( S l o t M o t o r X )   =   v 1 
 
 	 	 W a i t   S e c o n d s   0 . 0 1 
 
 	 N e x t 
 
 R e t u r n 
 
 
 
 L a b e l   M o v e M o t o r Y 
 
 	 v 2   =   S l o t ( S l o t M o t o r Y ) 
 
 	 v 3   =   v 2   +   M o v e B y 
 
 	 F o r   v 1   =   v 2   T o   v 3   S t e p   C u t S p e e d 
 
 	 	 S l o t ( S l o t M o t o r Y )   =   v 1 
 
 	 	 W a i t   S e c o n d s   0 . 0 1 
 
 	 N e x t 
 
 R e t u r n 
 
 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 ' - - - - -   S   U   B   R   O   U   T   I   N   E       A   R   E   A     - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 ' - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 
 
 
 '   = = = = = = = = = = = = =   H O M E   A L L   M O T O R S   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   " H O M E   A l l " 
 
 	 G o s u b   B L U 
 
 	 G o s u b   " H o m e   M 2 ( Z ) " 
 
 	 G o s u b   " H o m e   M 1 ( Y ) " 
 
 	 G o s u b   " H o m e   M 0 ( X ) " 
 
 R e t u r n 
 
 
 
 L a b e l   " H o m e   M 0 ( X ) " 
 
 	 S l o t M o t o r   =   S l o t M o t o r X 
 
 	 S l o t S e n s o r   =   1 9 
 
 	 S p e e d S e a r c h   =   -   0 . 0 5 	 	 ' - 0 . 1 
 
 	 S p e e d R e t u r n   =   +   0 . 0 0 5 
 
 	 D e c l a r e d Z e r o   =   0 
 
 	 I n i t i a l P o s i t i o n   =   2 
 
 	 G o s u b   " H o m e " 
 
 R e t u r n 
 
 
 
 L a b e l   " H o m e   M 1 ( Y ) " 
 
 	 S l o t M o t o r   =   S l o t M o t o r Y 
 
 	 S l o t S e n s o r   =   2 0 
 
 	 S p e e d S e a r c h   =   -   0 . 0 5 	 	 ' - 0 . 1 
 
 	 S p e e d R e t u r n   =   +   0 . 0 5 
 
 	 D e c l a r e d Z e r o   =   0 
 
 	 I n i t i a l P o s i t i o n   =   2 
 
 	 G o s u b   " H o m e " 
 
 R e t u r n 
 
 
 
 L a b e l   " H o m e   M 2 ( Z ) " 
 
 	 S l o t M o t o r   =   S l o t M o t o r Z 
 
 	 S l o t S e n s o r   =   2 1 
 
 	 S p e e d S e a r c h   =   +   0 . 0 5 
 
 	 S p e e d R e t u r n   =   -   0 . 0 0 5 
 
 	 D e c l a r e d Z e r o   =   1 0 3 
 
 	 I n i t i a l P o s i t i o n   =   1 0 0 
 
 	 G o s u b   " H o m e " 
 
 R e t u r n 
 
 
 
 L a b e l   " M o v e T o C o o r d s " 
 
 	 S l o t ( S l o t M o t o r Y )   =   C o o r d _ Y 
 
 	 G o s u b   W a i t A l l M o t o r s 
 
 	 S l o t ( S l o t M o t o r X )   =   C o o r d _ X 
 
 	 G o s u b   W a i t A l l M o t o r s 
 
 	 S l o t ( S l o t M o t o r Z )   =   C o o r d _ Z 
 
 	 G o s u b   W a i t A l l M o t o r s 
 
 R e t u r n 
 
 
 
 
 
 '   = = = = = = = = = = = = = = =   H O U S E   A L L   M O T O R S   M 0 ,   M 1 ,   M 3   = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   " H O U S E " 
 
 	 G o s u b   B L U 
 
 	 S l o t ( S l o t M o t o r Z )     =     9 8 	   	 ' Z   R a i s e 
 
 	 G o s u b   W a i t A l l M o t o r s 
 
 	 S l o t ( S l o t M o t o r X )     =     2           	 ' X   g o   t o   H O U S E 
 
 	 S l o t ( S l o t M o t o r Y )     =     2           	 ' Y   g o   t o   H O U S E 
 
 	 G o s u b   W a i t A l l M o t o r s 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   H O M E   M O T O R   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   " H o m e " 
 
 	 G o s u b   B l u 
 
 	 I f   S l o t ( S l o t S e n s o r )   >   5 0 0             '   d e t a c h   i f   s e n s o r   a c t i v e 
 
 	 	 S l o t ( S l o t M o t o r )   =   S l o t ( S l o t M o t o r )   +   S p e e d R e t u r n 
 
 	 E n d I f 
 
 ' 
 
 L a b e l   S e a r c h H o m e 
 
 	 S l o t ( S l o t M o t o r )   =   S l o t ( S l o t M o t o r )   +   S p e e d S e a r c h 
 
 	 W a i t   S e c o n d s   0 . 0 0 1 
 
 	 I f   S l o t ( S l o t S e n s o r )   >   5 0 0   	 '   l i m i t   s w i t c h 
 
 	 	 G o s u b   W a i t M o t o r 	 	 	 '   W A I T   U N T I L   M O T O R   S T O P 
 
 	 	 W a i t   S e c o n d s   0 . 1 	 	 '   t a b i l i z e   m e c h a n i c a l l y 
 
 	 	 G o t o   D e t a c h S e n s o r 
 
 	 E n d I f 
 
 G o t o   S e a r c h H o m e 
 
 ' 
 
 L a b e l   D e t a c h S e n s o r 
 
 	 S l o t ( S l o t M o t o r )   =   S l o t ( S l o t M o t o r )   +   S p e e d R e t u r n   '   d i r e c t i o n / s p e e d   r e t u r n 
 
 	 W a i t   S e c o n d s   0 . 0 0 1 
 
 	 I f   S l o t   ( S l o t S e n s o r )   <   5 0 0 
 
 	 	 G o s u b   W a i t M o t o r 
 
 	 	 G o t o   A s s i g n Z e r o 
 
 	 E n d I f 
 
 G o t o   D e t a c h S e n s o r 
 
 ' 
 
 L a b e l   A s s i g n Z e r o 
 
 	 S l o t ( S l o t M o t o r )   =   R e s e t 	 	 	 '   R e s e t   t h e   s l o t   v a l u e 
 
 	 W a i t   S e c o n d s   0 . 1 	 	     	 	 '   D O   N O T   T O U C H   T H E   V A L U E ,   n e e d e d   t o   t h e   M a s t e r ! ! ! ! 
 
 	 S l o t ( S l o t M o t o r )   =   D e c l a r e d Z e r o 
 
 	 G o s u b   W a i t M o t o r 
 
 	 S l o t ( S l o t M o t o r )   =   I n i t i a l P o s i t i o n 
 
 	 G o s u b   W a i t M o t o r 
 
 	 G o s u b   B L U 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   W   A   I   T   u n t i l   t h e   m o t o r ( S l o t M o t o r )   i s   s t o p p e d   = = = = = = = = 
 
 L a b e l   W a i t M o t o r 
 
 	 W a i t   S e c o n d s   0 . 1 
 
 	 L a b e l   W a i t 1 
 
 	 	 I f   A b s ( S l o t ( S l o t M o t o r   +   1 ) )   <   0 . 0 1 
 
 	 	 	 R e t u r n 	 	 	 '   n o w   t h e   m o t o r   i s   n o t   r u n n i n g 
 
 	 	 E n d I f 
 
 	 	 W a i t   S e c o n d s   0 . 0 0 5 
 
 	 G o t o   W a i t 1 
 
 G o t o   W a i t M o t o r 
 
 
 
 '   = = = = = = = = = = = = = = =   W   A   I   T     a l l   M O T O R S   a r e   S T O P P E D   = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   W a i t A l l M o t o r s 
 
 	 W a i t   S e c o n d s   0 . 1 
 
 	 L a b e l   W a i t A l l M o t o r s 2 
 
 	 	 I f   A b s ( S l o t ( S l o t M o t o r X + 1 ) )   <   0 . 0 1   A n d   A b s ( S l o t ( S l o t M o t o r Y + 1 ) )   <   0 . 0 1   A n d   A b s ( S l o t ( S l o t M o t o r Z + 1 ) )   <   0 . 0 1 
 
 	 	 	 R e t u r n 
 
 	 	 E n d I f 
 
 	 	 W a i t   S e c o n d s   0 . 0 1 
 
 	 G o t o   W a i t A l l M o t o r s 2 
 
 G o t o   W a i t A l l M o t o r s 
 
 
 
 '   = = = = = = = = = = = = = = =   E N A B L E   /   D I S A B L E   M O T O R S   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 ' L a b e l   E n a b l e M o t o r 
 
 ' 	 S l o t   1 1   =   0 
 
 ' 	 W a i t   S e c o n d s   0 . 2 
 
 ' R e t u r n 
 
 ' 
 
 ' L a b e l   D i s a b l e M o t o r 
 
 ' 	 S l o t   1 1   =   1 0 0 0 
 
 ' 	 W a i t   S e c o n d s   0 . 2 
 
 ' R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   T R A F F I C   L I G H T   C O L O R   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   R E D 
 
 	 S l o t   1 6   =   8 0 0 	 	 ' R E D 
 
 	 S l o t   1 7   =         0 	 	 ' G R E 
 
 	 S l o t   1 8   =         0 	 	 ' B L U 
 
 R e t u r n 
 
 
 
 L a b e l   G R E 
 
 	 S l o t   1 6   =         0 	 	 ' R E D 
 
 	 S l o t   1 7   =     8 0 0 	 	 ' G R E 
 
 	 S l o t   1 8   =         0 	 	 ' B L U 
 
 R e t u r n 
 
 
 
 L a b e l   B L U 
 
 	 S l o t   1 6   =         0 	 	 ' R E D 
 
 	 S l o t   1 7   =         0 	 	 ' Y E L 
 
 	 S l o t   1 8   =     8 0 0 	 	 ' B L U 
 
 R e t u r n 
 
 
 
 L a b e l   W H I 
 
 	 S l o t   1 6   =     7 0 0 	 	 ' R E D 
 
 	 S l o t   1 7   =     7 0 0 	 	 ' Y E L 
 
 	 S l o t   1 8   =     7 0 0 	 	 ' B L U 
 
 R e t u r n 
 
 
 
 '   = = = = = = = = = = = = = = =   M O V E   U S I N G   K E Y B O A R D   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 L a b e l   M o v e R i g h t 
 
 	 S l o t ( S l o t M o t o r X )   =   S l o t ( S l o t M o t o r X )   +   1 
 
 R e t u r n 
 
 
 
 L a b e l   M o v e L e f t 
 
 	 S l o t ( S l o t M o t o r X )   =   S l o t ( S l o t M o t o r X )   -   1 
 
 R e t u r n 
 
 
 
 L a b e l   M o v e F a r 
 
 	 S l o t ( S l o t M o t o r Y )   =   S l o t ( S l o t M o t o r Y )   +   1 
 
 R e t u r n 
 
 
 
 L a b e l   M o v e N e a r 
 
 	 S l o t ( S l o t M o t o r Y )   =   S l o t ( S l o t M o t o r Y )   -   1 
 
 R e t u r n 
 
 
 
 L a b e l   M o v e U p 
 
 	 S l o t ( S l o t M o t o r Z )   =   S l o t ( S l o t M o t o r Z )   +   1 
 
 R e t u r n 
 
 
 
 L a b e l   M o v e D o w n 
 
 	 S l o t ( S l o t M o t o r Z )   =   S l o t ( S l o t M o t o r Z )   -   1 
 
 R e t u r n 
 
 
 
 ' = = = = = =   D U M M Y   A R E A   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 ' = = = = = =   T O   D O   A R E A   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 ' = = = = = =   S E T   U P   A R E A   = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = 
 
 
 
 
 
 ' W A T C H   S l o t M o t o r 
 
 ' W A T C H   A b s ( S l o t ( S l o t M o t o r ) ) 
 
 ' E X E C   S i n 2   =   S i n ( 3 3 ) 
 
 